home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / sort2.zip / FINDFLD.FUN < prev    next >
Text File  |  1993-01-04  |  766b  |  21 lines

  1. function findfield(fldnum:integer; s:string):byte;
  2. { find field returns the first column of the the fldnum "awk" field
  3.   -- zero or more blanks followed by one or more non-blanks }
  4. { Copyright 1988,1989, by J. W. Rider }
  5.  
  6. { Externally, "delimset" (set of char) must be created with the valid
  7.   field delimiters.  Otherwise, white space is assume to be the only valid
  8.   delimiter. }
  9.  
  10. var i,fc:integer; inblank: boolean;
  11. begin fc:=1; i:=1; inblank:=true;
  12. while (i<=length(s)) and (fc<fldnum) do
  13.   if delimset=[] then
  14.     if s[i] in [^I,' '] then if not inblank then begin
  15.        inc(fc); inblank:=true end else inc(i)
  16.     else begin inblank:=false; inc(i) end
  17.   else begin if s[i] in delimset then inc(fc);
  18.        inc(i); end;
  19. findfield:=i; end;
  20.  
  21.